<template>
    <div class="house-item">
        <div class="house-inner">
            <div class="image">
                <img :src="item.image.url" alt="">
            </div>
            <div class="info">
                <div class="summary">{{ item.summaryText }}</div>
                <div class="name">{{ item.houseName }}</div>
                <div class="tips">
                    <div class="stars" >
                        <van-rate v-model="starValue" readonly allow-half size="12px"/>
                    </div>
                    <div class="price">
                        ￥{{ item.finalPrice }}
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script setup>
import { ref } from 'vue';

const props = defineProps({
    item: {
        type: Object,
        default: () => ({})
    }
})

const starValue = ref(Number(props.item.commentScore));
</script>

<style lang="less" scoped>
.house-item {
    // 每个item宽度占屏幕一半
    width: 50%;

    .house-inner {
        // 信息在img上：子绝父相
        position: relative;

        margin: 5px;

        .image {
            img {
                width: 100%;
                border-radius: 6px;
            }
        }

        .info {
            position: absolute;
            bottom: 0;

            padding: 8px 10px;

            color: #fff;

            .summary {
                font-size: 12px;
            }

            .name {
                // 超过2行就省略号省略...
                overflow: hidden;
                text-overflow: ellipsis;
                display: -webkit-box;
                -webkit-line-clamp: 2;
                -webkit-box-orient: vertical;

                margin: 5px 0;
            }

            .tips{
                display: flex;
                justify-content: space-between;
            }
        }

    }
}
</style>